from django.db import models

# Create your models here.
class Redeem(models.Model):
    """
    卡密管理-兑换码
    status: 是否兑换, 0 未核销，1 已核销
    {
        "id": 2,
        "user_id": 0,
        "name": "100算力点卡",
        "username": "",
        "power": 100,
        "code": "a08679cef5814c316d952f42aff2ed99",
        "enabled": true,
        "redeemed_at": 0,
        "created_at": 1729667030,
        "status": "0/1".
    }
    """
    id = models.BigAutoField(primary_key=True)
    user_id = models.IntegerField(verbose_name="用户ID", blank=True, null=True, default=None)
    name = models.CharField(verbose_name="产品名称", max_length=128, blank=False, null=False)
    username = models.CharField(verbose_name="用户名", max_length=32, blank=True, null=True, default=None)
    power = models.IntegerField(verbose_name="产品算力", blank=False, null=False, default=0)
    code = models.CharField(verbose_name="兑换码", max_length=32, blank=False, null=False)
    enabled = models.BooleanField(verbose_name="启用状态", blank=False, null=False, default=True)

    status = models.BooleanField(verbose_name="是否兑换", blank=False, null=False, default=False)

    redeemed_at = models.DateTimeField(verbose_name="兑换时间", null=True, blank=True, default=None)
    created_at = models.DateTimeField(auto_now_add=True)

